package com.wuchaooooo.service.zjutsds.dao;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.wuchaooooo.service.zjutsds.pojo.po.PCareer;
import com.wuchaooooo.service.zjutsds.pojo.po.PQuestion;
import com.wuchaooooo.service.zjutsds.pojo.po.PUser;

/**
 * Created by wuchaooooo on 08/06/2017.
 */
@Repository
public class QuestionDAO {
    private static final Logger LOGGER = LoggerFactory.getLogger(QuestionDAO.class);

    @Resource(name = "primaryJdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    public List<PQuestion> getQuestion() {
        
        String sql = "select * from " + getTable();
        RowMapper<PQuestion> rowMapper = new BeanPropertyRowMapper<>(PQuestion.class);
        try {
            return jdbcTemplate.query(sql, rowMapper);
        } catch (EmptyResultDataAccessException e) {
            return null;
        }
    }

    private String getTable() {
        return "question";
    }

}
